/***************************************************************************
 创建者：华磊
 开始时间：         : 2020.12.19
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   坐标系指令属性编辑视窗
*                                                                         *
 ***************************************************************************/
#include "coordinateinstructiondelegate.h"


CoordinateInstructionDelegate::CoordinateInstructionDelegate(QWidget *parent):
    QObject(parent)
{
}

void CoordinateInstructionDelegate::initialView()
{
    coordinateInstructionView->instruction = "UTOOL";

    coordinateInstructionView->selectType = EM_COORDINATE_SETTING_TOOL;

    coordinateInstructionView->setToolIndex = 1;
    coordinateInstructionView->setFrameIndex = 1;

    coordinateInstructionView->toolPRValue = 1;
    coordinateInstructionView->framePRValue = 1;
    coordinateInstructionView->selectToolValue = "1";
    coordinateInstructionView->selectFrameValue = "1";

    coordinateInstructionView->note = "";

    //coordinateInstructionView->updateView();
}

void CoordinateInstructionDelegate::selectSetToolInstructionSlot()
{
    coordinateInstructionView->selectType = EM_COORDINATE_SETTING_TOOL;
    coordinateInstructionView->updateView();

    qDebug("select set tool");
}

void CoordinateInstructionDelegate::selectSetFrameInstructionSlot()
{
    coordinateInstructionView->selectType = EM_COORDINATE_SETTING_FRAME;
    coordinateInstructionView->updateView();

    qDebug("select set frame");
}

void CoordinateInstructionDelegate::selectToolNumInstructionSlot()
{
    coordinateInstructionView->selectType = EM_COORDINATE_SETTING_TOOL_NUM;
    coordinateInstructionView->updateView();

    qDebug("select change tool num");
}

void CoordinateInstructionDelegate::selectFrameNumInstructionSlot()
{
    coordinateInstructionView->selectType = EM_COORDINATE_SETTING_FRAME_NUM;
    coordinateInstructionView->updateView();

    qDebug("select change frame num");
}

void CoordinateInstructionDelegate::clearNoteSlot()
{
    coordinateInstructionView->note.clear();

    qDebug("clear note");
}

void CoordinateInstructionDelegate::finishEditInstructionSlot()
{
    if(EM_COORDINATE_SETTING_TOOL == coordinateInstructionView->selectType)
    {
        coordinateInstructionView->instruction = "UTOOL";
        coordinateInstructionView->instruction += "[" + QString::number(coordinateInstructionView->setToolIndex) + "]"
                + "=" + "PR[" + QString::number(coordinateInstructionView->toolPRValue) + "]";
    }
    else if(EM_COORDINATE_SETTING_FRAME == coordinateInstructionView->selectType)
    {
        coordinateInstructionView->instruction = "UFRAME";
        coordinateInstructionView->instruction += "[" + QString::number(coordinateInstructionView->setFrameIndex) + "]"
                + "=" + "PR[" + QString::number(coordinateInstructionView->framePRValue) + "]";
    }
    else if(EM_COORDINATE_SETTING_TOOL_NUM == coordinateInstructionView->selectType)
    {
        coordinateInstructionView->instruction = "UTOOL_NUM";
        coordinateInstructionView->instruction += "=" + coordinateInstructionView->selectToolValue ;
    }
    else if(EM_COORDINATE_SETTING_FRAME_NUM == coordinateInstructionView->selectType)
    {
        coordinateInstructionView->instruction = "UFRAME_NUM";
        coordinateInstructionView->instruction += "=" + coordinateInstructionView->selectFrameValue ;
    }

    coordinateInstructionView->instruction = coordinateInstructionView->instruction + ";" + " //" + coordinateInstructionView->note;
}
